{extends 'base/site2.html'}
{block name="page_header"}{include file="common/header.html" inline}{/block}
{block name="page_nav"}{include file="common/slide-nav.html" inline}{/block}
{block name="page_styles"}
    <link rel="stylesheet" type="text/css" href="/css/mediation/assets/addandedit.css" />
{/block}

{block name="page_section"}
    <input type="hidden" role-ele="add">
        <div class="sessionPage bg-fff">
        <div class="page-header">
          <div class="left">
            <span class="line"></span>
            <strong class="tit">资产方{if empty($info)}添加{else}编辑{/if}</strong>
          </div>
        </div>
        <div class="row mr-none">
            <form class="form-horizontal col-lg-7 pad-no"  method="post" valid-after="true">
                <input type="hidden" name="id" value="{if !empty($info['id'])}{$info['id']}{/if}">

                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-3 control-label">资产方名称</label>
                    <div class="col-sm-9">
                        <input type="text" name="assets[name]" value="{if !empty($info['name'])}{$info['name']}{/if}" class="form-control" id="inputEmail3" placeholder="请输入~" data-valid="notempty">
                        <span class="error-tips"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-3 control-label">申请调解方</label>
                    <div class="col-sm-9">
                        <input type="text" name="assets[applyName]" value="{if !empty($info['applyName'])}{$info['applyName']}{/if}" class="form-control" id="inputEmail3" placeholder="非必填，区分资产方使用~" data-valid="notempty">
                        <span class="error-tips"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-3 control-label">接入类型</label>
                    <div class="col-sm-9">
                        <select name="assets[accessType]" class="form-control" id="access_type">
                            <option class="u144_input_option" selected="selected" value="">请选择</option>
                            {foreach from=$accessType key=key item=item}
                                <option {if !empty($info['accessType']) &&  $info['accessType']== $key} selected="selected" {/if} value="{$key}">{$item}</option>
                            {/foreach}
                        </select>
                        <span class="error-tips"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-3 control-label">线路1外显号</label>
                    <div class="col-sm-9">
                        <select name="assets[outNumber]" class="form-control" id="outNumber">
                            <option class="u144_input_option" selected="selected" value="">请选择</option>
                            {foreach from=$callNum item=item}
                            <option {if !empty($info['outNumber']) &&  $info['outNumber'] == $item} selected="selected" {/if} value="{$item}">{$item}-{$numCard[$item]}</option>
                            {/foreach}
                        </select>
                        <span class="error-tips">可不选择，默认外显为坐席绑定号码，选择则优先外显资产方绑定号码</span>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-3 control-label">线路2外显号</label>
                    <div class="col-sm-9">
                        <select name="assets[outNumber2]" class="form-control" id="outNumber2">
                            <option class="u144_input_option" selected="selected" value="">请选择</option>
                            {foreach from=$callNum2 item=item}
                            <option {if !empty($info['outNumber2']) &&  $info['outNumber2']== $item} selected="selected" {/if} value="{$item}">{$item}-{$numCard[$item]}</option>
                            {/foreach}
                        </select>
                        <span class="error-tips">可不选择，默认外显为坐席绑定号码，选择则优先外显资产方绑定号码</span>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-3 control-label">短信签名</label>
                    <div class="col-sm-9">
                        <select name="assets[smsSign]" class="form-control" id="smsSign">
                            <option class="u144_input_option" selected="selected" value="">请选择</option>
                            {foreach from=$smsSign key=key item=item}
                            <option {if !empty($info['smsSign']) &&  $info['smsSign']== $key} selected="selected" {/if} value="{$key}">{$item}</option>
                            {/foreach}
                        </select>
                        <span class="error-tips"></span>

                    </div>
                </div>
                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-3 control-label">短信中心名称</label>
                    <div class="col-sm-9">
                        <select name="assets[smsCenterName]" class="form-control" id="smsCenterName">
                            <option class="u144_input_option" selected="selected" value="">请选择</option>
                            {foreach from=$centerName key=key item=item}
                            <option {if !empty($info['smsCenterName']) &&  $info['smsCenterName']== $key} selected="selected" {/if} value="{$key}">{$item}</option>
                            {/foreach}
                        </select>
                        <span class="error-tips">建议若是特邀签名，选择调解中心名称，调解中心签名，选择特邀名称</span>
                    </div>
                </div>
                <div class="form-group" style="display:none" id="appid">
                    <label for="inputEmail3" class="col-sm-3 control-label">appid</label>
                    <div class="col-sm-9">
                        <input type="tel" name="assets[appid]" value="{if !empty($info['appid'])}{$info['appid']}{/if}" class="form-control" id="inputEmail3" placeholder="请输入~" data-valid="notempty">
                        <span class="error-tips"></span>
                    </div>
                </div>
                <div class="form-group" style="display:none" id="white_ip" >
                    <label for="inputEmail3" class="col-sm-3 control-label">白名单IP</label>
                    <div class="col-sm-9">
                        <textarea name="assets[whiteIp]" class="form-control" rows="3" style="width: 98%;">{if !empty($info['whiteIp'])}{$info['whiteIp']}{/if}</textarea>

                        <span class="error-tips"></span>
                    </div>
                </div>

                <div class="form-group" style="display:none" id="apiAddress">
                    <label for="inputEmail3" class="col-sm-3 control-label">接口地址</label>
                    <div class="col-sm-9">
                        <input type="tel" name="assets[apiAddress]" value="{if !empty($info['apiAddress'])}{$info['apiAddress']}{/if}" class="form-control" id="inputEmail3" placeholder="请输入~" data-valid="notempty">
                        <span class="error-tips"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-3 control-label">备注</label>
                    <div class="col-sm-9">
                        <textarea name="assets[desc]" class="form-control" cols="50" rows="7">{if !empty($info['desc'])}{$info['desc']}{/if}</textarea>
                        <span class="error-tips"></span>
                    </div>
                </div>

                <div class="form-group mr-t50 mr-b20">
                    <button type="button" id="submit" class="btn btn-primary  col-lg-2 col-md-offset-2">保存</button>
                    <a href="/assets/index">
                        <button type="button" class="btn btn-default  col-lg-2 col-md-offset-2">返回</button>
                    </a>
                </div>
            </form>
        </div>
    </div>
{/block}
{block name="page_scripts"}
{*    <script type="text/javascript" src="/js/mediation/assets/addandedit.min.js" init="mediation/assets/addandedit"></script>*}
    <script type="text/javascript">
        $(document).ready(function(){
           if($("#access_type").val()==2){
               $("#appid").show();
               $("#white_ip").show();
               $("#apiAddress").show();
           }

        });
        $("#access_type").change(function(){
            var type = $(this).val();
            if(type==2){
                $("#appid").show();
                $("#white_ip").show();
                $("#apiAddress").show();

            }else{
                $("#appid").hide();
                $("#white_ip").hide();
                $("#apiAddress").hide();
            }
        });
        var lockfas =  false;
        $("#submit").on("click",function(){
            if(lockfas)return;
            lockfas = true;

            $.ajax({
                type: "post",
                url:"/assets/addAndEdit",
                data:$(".form-horizontal").serialize(),
                dataType:'json',
                success:function(res){
                    if(res.code==200){
                        lockfas = false;
                        toastr.success(res.message);
                        setTimeout(function(){
                            window.location.href="/assets/index";
                        },2000)
                    }else{
                        lockfas = false;
                        toastr.error(res.message);
                    }
                }
            })
            lockfas = false;

        })
    </script>
{/block}
